package models

import (
	"crypto/md5"
	"encoding/hex"
	"github.com/astaxie/beego/orm"
)

type Admin struct {
	App
}

//生成密码Hash
func (m *Admin) GeneratePassword(password string) string {
	md5Byte := md5.Sum([]byte(password))
	//取前10字节二次加密防止暴力破解
	md5Byte = md5.Sum(md5Byte[0:11])
	return hex.EncodeToString(md5Byte[0:16])
}

//NewAdmin
func NewAdmin(ormer orm.Ormer) *Admin {
	o := &Admin{
	}
	o.Ormer = ormer
	o.FlagFiled = map[string]map[int8]string{
		"Status": {
			0: "锁定",
			1: "正常",
		},
	}
	return o
}
